/**
 * Created by huangxuehua on 2018/4/8.
 */
var xpHome = new Vue({
    el: '#app',
    data: {
        showGoodsList:{},//获得商品信息
        userListInfo:[]//获取获利用户信息
    },
    methods: {

        getCouponPrice:function(price){ //替换 价格去零
            if(price){
                var prices = price.replace(".00","");
                return   prices;
            }
        },
        goodsList:function(){//动态获取 商品 并展示
            $.ajax({
                url: nUrls. getThreeGoodsInfo,
                type:'post',
                success:function(data){
                    var result = eval('('+data+')');
                    if(result && result.code == 200){
                        //console.log(result)
                        xpHome.showGoodsList = result.data;
                        console.log(xpHome.showGoodsList);
                    }
                },
                error:function(){
                    console.log("没有更多商品")
                }
            });
        },
         getUserPriceInfo:function(){
             $.ajax({
                 url: nUrls. getHuoDongInfo,
                 type:'post',
                 success:function(data){
                     var result = eval('('+data+')');
                     if(result && result.code == 200) {
                         xpHome.userListInfo =result. data;
                         console.log("xpHome.userListInfo", xpHome.userListInfo);
                         console.log("xpHome.userListInfo[0]", xpHome.userListInfo[0]);
                     }
                 },
                 error:function(){
                     console.log("获取用户信息失败")
                 }
             });
         },
        goGoodsDetail:function(goodsId){  //跳转商品详情页
            var qcode =nUtils.getUrlParam('qcode')
            var ordersn =nUtils.getUrlParam('ordersn');
            if(qcode&&ordersn){
                window.location.href=serverUrl+"?r=marketing/sharereb/godetail&qcode="+qcode+"&ordersn="+ordersn;
            }else{
                window.location.href="./detail/goods_detail.html?id="+goodsId
            }
        }
    }
})
$(function(){
    xpHome.goodsList();//获取产品信息
    xpHome.getUserPriceInfo();//获取用户获利信息
})